<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/jsp/manage/common/taglibs.jsp"%>
<c:if test="${initParam['ssoEnable']=='true'}">
    <%@ include file="/WEB-INF/jsp/manage/common/ssoInclude.jsp" %>
</c:if>
<script type="text/javascript">
$(function() {
	$.acooly.framework.registerKeydown('manage_businessConfig_searchform','manage_businessConfig_datagrid');
});
function loadBrAndCr() {
    load_manage_businessRule_datagrid();
    load_manage_channelRoute_datagrid();
}
/***
 * 加载选择的商户配置对应业务能力配置
 */
function load_manage_businessRule_datagrid() {
    $.acooly.framework.fireSelectRow('manage_businessConfig_datagrid', function (row) {
        $.acooly.framework.loadGrid({
            gridId: "manage_businessRule_datagrid",
            url: '/manage/businessrule/businessRule/listJson.html',
            ajaxData: {"search_EQ_merchantCode": row.merchantCode}
        });
    }, '请先选择操作的商户数据行');
}
/***
 * 加载选择的商户配置对应渠道规则配置
 */
function load_manage_channelRoute_datagrid() {
    $.acooly.framework.fireSelectRow('manage_businessConfig_datagrid', function (row) {
        $.acooly.framework.loadGrid({
            gridId: "manage_routeRule_datagrid",
            url: '/manage/routerule/routeRule/listJson.html',
            ajaxData: {"search_EQ_partnerId": row.partnerId}
        });
    }, '请先选择操作的商户数据行');
}
/**
 *  商户能力配置: 添加界面
 */
function create_manage_BusinessRule_add_view() {
    //判断是否选择商户接入主表行，如果选择，则回调传入当前选中行的数据。
    $.acooly.framework.fireSelectRow('manage_businessConfig_datagrid', function (row) {
        $.acooly.framework.create({
            url: '/manage/businessrule/businessRule/create.html',
            entity: 'businessRule',
            width: 900, height: 500,
            ajaxData: {'partnerId': row.partnerId}
        });
    }, '请先选择操作的商户数据行');
}
/**
 *  商户路由规则配置: 添加界面
 */
function create_manage_ChannelRouteRule_add_view() {
    //判断是否选择商户接入主表行，如果选择，则回调传入当前选中行的数据。
    $.acooly.framework.fireSelectRow('manage_businessConfig_datagrid', function (row) {
        $.acooly.framework.create({
            url: '/manage/routerule/routeRule/create.html',
            entity: 'routeRule',
            width: 900, height: 500,
            ajaxData: {'partnerId':row.partnerId}
        });
    }, '请先选择操作的商户数据行');
}
/**
 * 商户能力配置: 编辑界面
 */
function create_manage_businessrule_edit_view(sectionId) {
    //判断是否选择客户主表行，如果选择，则回调传入当前选中行的数据。
    $.acooly.framework.fireSelectRow('manage_businessConfig_datagrid', function (row) {
        $.acooly.framework.edit({
            url: '/manage/businessrule/businessRule/edit.html?date=' + new Date(),
            id: sectionId,
            entity: 'businessRule',
            width: 900, height: 500,
            ajaxData: {'partnerId': row.partnerId},
            onSuccess: function () {
                load_manage_businessRule_datagrid();
            }
        });
    }, '请先选择操作的清分场景数据行');
}
/**
 * 路由规则配置: 编辑界面
 */
function create_manage_channelroute_edit_view(sectionId) {
    //判断是否选择客户主表行，如果选择，则回调传入当前选中行的数据。
    $.acooly.framework.fireSelectRow('manage_businessConfig_datagrid', function (row) {
        $.acooly.framework.edit({
            url: '/manage/routerule/routeRule/edit.html?date=' + new Date(),
            id: sectionId,
            entity: 'routeRule',
            width: 900, height: 500,
            ajaxData: {'partnerId':row.partnerId},
            onSuccess: function () {
                load_manage_channelRoute_datagrid();
            }
        });
    }, '请先选择操作的商户数据行');
}
</script>
<div class="easyui-layout" data-options="fit : true,border : false">
  <!-- 查询条件 -->
    <form id="manage_businessConfig_searchform" onsubmit="return false">
        <table class="tableForm" width="100%">
            <tr>
                <td align="left">
                    <div>
                        商户号: <input type="text" class="text" size="15" name="search_LIKE_partnerId"/>
                        状态: <select style="width:80px;height:27px;" name="search_EQ_status" editable="false" panelHeight="auto" class="easyui-combobox"><option value="">所有</option><c:forEach var="e" items="${allStatuss}"><option value="${e.key}" ${param.search_EQ_status == e.key?'selected':''}>${e.value}</option></c:forEach></select>
                        托管模式: <select style="width:80px;height:27px;" name="search_EQ_trustModel" editable="false" panelHeight="auto" class="easyui-combobox"><option value="">全部</option><c:forEach var="e" items="${allTrusts}"><option value="${e.key}" ${param.search_EQ_trustModel == e.key?'selected':''}>${e.value}</option></c:forEach></select>
                        <a href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:false" onclick="$.acooly.framework.search('manage_businessConfig_searchform','manage_businessConfig_datagrid');"><i class="fa fa-search fa-lg fa-fw fa-col"></i>查询</a>
                    </div>
                </td>
            </tr>
        </table>
    </form>

  <!-- 列表和工具栏 -->
    <div data-options="region:'center',border:false" style="overflow: hidden;height:40%" align="left">
    <table id="manage_businessConfig_datagrid" class="easyui-datagrid" url="${pageContext.request.contextPath}/manage/businessconfig/businessConfig/listJson.html" toolbar="#manage_businessConfig_toolbar" fit="true" border="false" fitColumns="false"
      pagination="true" idField="id" pageSize="20" pageList="[ 10, 20, 30, 40, 50 ]" sortName="id" sortOrder="desc" checkOnSelect="true" selectOnCheck="true" singleSelect="true" data-options="onClickRow:loadBrAndCr">
      <thead>
        <tr>
        	<th field="showCheckboxWithId" checkbox="true" data-options="formatter:function(value, row, index){ return row.id }">编号</th>
			<th field="partnerId">商户号</th>
            <th field="trustModel" data-options="formatter:function(value){ return formatRefrence('manage_businessConfig_datagrid','allTrusts',value);} ">托管模式</th>
            <th field="status" formatter="mappingFormatter">状态</th>
            <th field="memo">备注</th>
            <th field="rowActions" data-options="formatter:function(value, row, index){return formatAction('manage_businessConfig_action',value,row)}">动作</th>
        </tr>
      </thead>
    </table>

    <!-- 每行的Action动作模板 -->
    <div id="manage_businessConfig_action" style="display: none;">
      <a onclick="$.acooly.framework.edit({url:'/manage/businessconfig/businessConfig/edit.html',id:'{0}',entity:'businessConfig',width:500,height:400});" href="#" title="编辑"><i class="fa fa-pencil fa-lg fa-fw fa-col"></i></a>
      <a onclick="$.acooly.framework.show('/manage/businessconfig/businessConfig/show.html?id={0}',500,400);" href="#" title="查看"><i class="fa fa-file-o fa-lg fa-fw fa-col"></i></a>
      <a onclick="$.acooly.framework.remove('/manage/businessconfig/businessConfig/deleteJson.html','{0}','manage_businessConfig_datagrid');" href="#" title="删除"><i class="fa fa-trash-o fa-lg fa-fw fa-col"></i></a>
    </div>

    <!-- 表格的工具栏 -->
    <div id="manage_businessConfig_toolbar">
      <a href="#" class="easyui-linkbutton" plain="true" onclick="$.acooly.framework.create({url:'/manage/businessconfig/businessConfig/create.html',entity:'businessConfig',width:500,height:400})"><i class="fa fa-plus-circle fa-lg fa-fw fa-col"></i>添加</a>
      <a href="#" class="easyui-linkbutton" plain="true" onclick="$.acooly.framework.removes('/manage/businessconfig/businessConfig/deleteJson.html','manage_businessConfig_datagrid')"><i class="fa fa-trash-o fa-lg fa-fw fa-col"></i>批量删除</a>
    </div>
  </div>
    <!-- 列表和工具栏 -->
    <div data-options="region:'south',border:false" style="height:58%;">
        <div id="manage_businessrul_sub_tab" class="easyui-tabs" fit="true">
            <!-- 子列表: 业务规则配置 -->
            <div title="商户能力配置" style="margin-left: 0px;">
                <table id="manage_businessRule_datagrid" class="easyui-datagrid"  toolbar="#manage_businessRule_toolbar" fit="true" border="false" fitColumns="false"
                       pagination="true" idField="id" pageSize="20" pageList="[ 10, 20, 30, 40, 50 ]" sortName="id" sortOrder="desc" checkOnSelect="true" selectOnCheck="true" singleSelect="false">
                    <thead>
                    <tr>
                        <th field="showCheckboxWithId" checkbox="true" data-options="formatter:function(value, row, index){ return row.id }">编号</th>
                        <th field="transactionType" data-options="formatter:function(value){ return formatRefrence('manage_businessRule_datagrid','allTransactionTypes',value);} ">交易类型</th>
                        <th field="subTransactionType" data-options="formatter:function(value){ return formatRefrence('manage_businessRule_datagrid','allSubTransactionTypes',value);}">子交易类型</th>
                        <th field="personalCorporateType" data-options="formatter:function(value){ return formatRefrence('manage_businessRule_datagrid','allPersonalCorporateTypes',value);} ">对公对私</th>
                        <th field="cardType" data-options="formatter:function(value){ return formatRefrence('manage_businessRule_datagrid','allDebitCreditTypes',value);} ">借贷类型</th>
                        <th field="instBankId">银行编码</th>
                        <th field="status" data-options="formatter:function(value){ return formatRefrence('manage_businessRule_datagrid','allStatuss',value);} ">状态</th>
                        <th field="ruleName">规则名称</th>
                        <th field="memo">备注</th>
                        <th field="rowActions" data-options="formatter:function(value, row, index){return formatAction('manage_businessRule_action',value,row)}">动作</th>
                    </tr>
                    </thead>
                </table>

                <!-- 每行的Action动作模板 -->
                <div id="manage_businessRule_action" style="display: none;">
                    <a onclick="create_manage_businessrule_edit_view({0});" href="#" title="编辑"><i class="fa fa-pencil fa-lg fa-fw fa-col"></i></a>
                    <a onclick="$.acooly.framework.show('/manage/businessrule/businessRule/show.html?id={0}',500,400);" href="#" title="查看"><i class="fa fa-file-o fa-lg fa-fw fa-col"></i></a>
                    <a onclick="$.acooly.framework.remove('/manage/businessrule/businessRule/deleteJson.html','{0}','manage_businessRule_datagrid',null,null,function(){load_manage_businessRule_datagrid();});" href="#" title="删除"><i class="fa fa-trash-o fa-lg fa-fw fa-col"></i></a>
                </div>

                <!-- 表格的工具栏 -->
                <div id="manage_businessRule_toolbar">
                    <a href="#" class="easyui-linkbutton" plain="true" onclick="create_manage_BusinessRule_add_view()"><i class="fa fa-plus-circle fa-lg fa-fw fa-col"></i>添加</a>
                    <a href="#"  class="easyui-linkbutton" plain="true" onclick="$.acooly.framework.removes('/manage/businessrule/businessRule/deleteJson.html','manage_businessRule_datagrid',null,null,function(){load_manage_businessRule_datagrid();})"><i class="fa fa-trash-o fa-lg fa-fw fa-col"></i>批量删除</a>
                </div>
            </div>
            <!--子列表-->
            <div title="商户路由规则" style="margin-left: 0px;">
                <table id="manage_routeRule_datagrid" class="easyui-datagrid" toolbar="#manage_routeRule_toolbar" fit="true" border="false" fitColumns="false"
                       pagination="true" idField="id" pageSize="20" pageList="[ 10, 20, 30, 40, 50 ]" sortName="id" sortOrder="desc" checkOnSelect="true" selectOnCheck="true" singleSelect="false">
                    <thead>
                    <tr>
                        <th field="showCheckboxWithId" checkbox="true" data-options="formatter:function(value, row, index){ return row.id }">编号</th>
                        <th field="gatewayChannelApi">清算渠道API</th>
                        <th field="transactionType" data-options="formatter:function(value){ return formatRefrence('manage_routeRule_datagrid','allTransactionTypes',value);} ">交易类型</th>
                        <th field="subTransactionType" data-options="formatter:function(value){ return formatRefrence('manage_routeRule_datagrid','allSubTransactionTypes',value);} ">子交易类型</th>
                        <th field="personalCorporateType" data-options="formatter:function(value){ return formatRefrence('manage_routeRule_datagrid','allPersonalCorporateTypes',value);} ">对公对私</th>
                        <th field="cardType" data-options="formatter:function(value){ return formatRefrence('manage_routeRule_datagrid','allDebitCreditTypes',value);} ">借贷类型</th>
                        <th field="status" data-options="formatter:function(value){ return formatRefrence('manage_routeRule_datagrid','allStatuss',value);} ">状态</th>
                        <th field="instBankId">银行编码</th>
                        <th field="amount" >规则金额</th>
                        <th field="calculateType" data-options="formatter:function(value){ return formatRefrence('manage_routeRule_datagrid','allCalculateTypes',value);} ">金额规则</th>
                        <th field="elementType" formatter="mappingFormatter">验证要素类型</th>
                        <th field="priority" >优先级</th>
                        <th field="weight" >流量权重</th>
                        <th field="extendField" >扩展参数</th>
                        <th field="memo">备注</th>
                        <th field="rowActions" data-options="formatter:function(value, row, index){return formatAction('manage_routeRule_action',value,row)}">动作</th>
                    </tr>
                    </thead>
                </table>

                <!-- 每行的Action动作模板 -->
                <div id="manage_routeRule_action" style="display: none;">
                    <a onclick="create_manage_channelroute_edit_view({0});" href="#" title="编辑"><i class="fa fa-pencil fa-lg fa-fw fa-col"></i></a>
                    <a onclick="$.acooly.framework.show('/manage/routerule/routeRule/show.html?id={0}',500,400);" href="#" title="查看"><i class="fa fa-file-o fa-lg fa-fw fa-col"></i></a>
                    <a onclick="$.acooly.framework.remove('/manage/routerule/routeRule/deleteJson.html','{0}','manage_routeRule_datagrid',null,null,function(){load_manage_channelRoute_datagrid();});" href="#" title="删除"><i class="fa fa-trash-o fa-lg fa-fw fa-col"></i></a>
                </div>

                <!-- 表格的工具栏 -->
                <div id="manage_routeRule_toolbar">
                    <a href="#" class="easyui-linkbutton" plain="true" onclick="create_manage_ChannelRouteRule_add_view()"><i class="fa fa-plus-circle fa-lg fa-fw fa-col"></i>添加</a>
                    <a href="#"  class="easyui-linkbutton" plain="true" onclick="$.acooly.framework.removes('/manage/routerule/routeRule/deleteJson.html','manage_routeRule_datagrid')"><i class="fa fa-trash-o fa-lg fa-fw fa-col"></i>批量删除</a>
                </div>
            </div>
        </div>
        </div>
</div>
